﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_QuanTri.AccessDatabase
{
    public class PhanNhomMenu
    {
        AccessData ac = new AccessData(1);
        public int updatethutu(int manhom,int menuid,int thutu)
        {
            SqlParameter[] arrPara = new SqlParameter[3];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            arrPara[1] = new SqlParameter("@MenuID", SqlDbType.Int);
            arrPara[1].Value = menuid;
            arrPara[2] = new SqlParameter("@ThuTu", SqlDbType.Int);
            arrPara[2].Value = thutu;
            DataTable dt = ac.ftblDocDuLieuSP("treeedittestupdatethutu", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loadtreeshowtest(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;

            return ac.ftblDocDuLieuSP("treeedittest", arrPara);

        }
        public int xoa(int id)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value = id;
         

            DataTable dt = ac.ftblDocDuLieuSP("phannhommenu_xoamenu", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loadmenushowtest(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;

            return ac.ftblDocDuLieuSP("showmenutestbynhom", arrPara);

        }
        public int sua( int id, int menucha,int command)
        {
            SqlParameter[] arrPara = new SqlParameter[3];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value = id;
            arrPara[1] = new SqlParameter("@MenuCha", SqlDbType.Int);
            arrPara[1].Value = menucha;
            arrPara[2] = new SqlParameter("@Command", SqlDbType.Int);
            arrPara[2].Value = command;
            DataTable dt = ac.ftblDocDuLieuSP("phannhommenu_suamenu", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int capnhatquyen(int id,int capnhat,int xem,int xoa)
        {
            SqlParameter[] arrPara = new SqlParameter[4];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value =id;
            arrPara[1] = new SqlParameter("@CapNhat", SqlDbType.Int);
            arrPara[1].Value = capnhat;
            arrPara[2] = new SqlParameter("@Xem", SqlDbType.Int);
            arrPara[2].Value = xem;
            arrPara[3] = new SqlParameter("@Xoa", SqlDbType.Int);
            arrPara[3].Value = xoa;
            DataTable dt = ac.ftblDocDuLieuSP("capnhatquyentrenmenu", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int them(int manhom,int menuid,int cap,int menucha,int command)
        {
            SqlParameter[] arrPara = new SqlParameter[5];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            arrPara[1] = new SqlParameter("@MenuID", SqlDbType.Int);
            arrPara[1].Value = menuid;
            arrPara[2] = new SqlParameter("@Cap", SqlDbType.Int);
            arrPara[2].Value = cap;
            arrPara[3] = new SqlParameter("@MenuCha", SqlDbType.Int);
            arrPara[3].Value = menucha;
            arrPara[4] = new SqlParameter("@Command", SqlDbType.Int);
            arrPara[4].Value = command;
            DataTable dt = ac.ftblDocDuLieuSP("phannhommenu_themmenu", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        //
        public DataTable loadmultimenuparent(int manhom,int cap)
        {
            SqlParameter[] arrPara = new SqlParameter[2];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            arrPara[1] = new SqlParameter("@menucap", SqlDbType.Int);
            arrPara[1].Value = cap;

            return ac.ftblDocDuLieuSP("loadmenuparent", arrPara);

        }
        public DataTable loadcombolever(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;

            return ac.ftblDocDuLieuSP("phannhommenu_loadlevermenu", arrPara);

        }
        public DataTable loadcombomenucon(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;

            return ac.ftblDocDuLieuSP("loadmenucon", arrPara);

        }
        public DataTable loadluoi(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;

            return ac.ftblDocDuLieuSP("phannhommenu_loaddanhsachnhommenu", arrPara);
            
        }
        public DataTable loadcombocommand()
        {

            return ac.ftblDocDuLieuSP("loadcombocommand", null);
        }
        public DataTable loadcombonhom()
        {

            return ac.ftblDocDuLieuSP("phannhommenu_loadnhommenu", null);
        }
    }
}
